<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <link rel="stylesheet" href="../css/long.css">
    <link rel="stylesheet" href="../css/publis.css">
</head>


<body>
    <div class="long">
        <p class="err">
            <span class="cuowu">账号密码不能为空</span>
        </p>
        <div class="long-top">
            <p>请输入身份证号</p>
            <p class="err">
                <span>身份证号错误，请输入正确的身份证号</span>
            </p>
            <input type="text" id="username">
        </div>
        <div class="long-bottom">
            <p>请输入手机号</p>
            <p class="err">
                <span>手机号错误，请输入正确的手机号</span>
            </p>
            <input type="password" id="password">
        </div>
        <button class="long-button">登录</button>
    </div>


    <script src="../js/jquery-3.6.0.min.js"></script>
    <script>
        $.ajax({
            url: 'http://127.0.0.1:4523/m1/2428366-0-default/long/1',
            type: 'get',
            datatype: 'json',
            async: false,
            success: function(res) {
                $('button').click(function() {
                    for (let i = 0; i < res.length; i++) {
                        console.log(res[i].password);
                        console.log(res[i].username);
                        var checkoutFlag = true;
                        // if (res[i].password == $('#password').val() && res[i].username == $('#username').val()) {
                        //     location.href = 'http://4q96s9.natappfree.cc/'
                        //     return false
                        // } else {
                        //     // console.log('登录失败');
                        //     window.alert('账号或者密码错误')
                        // }
                        if ($('#password').val() !== '' && $('#username').val() !== '') {
                            if (res[i].username == $('#username').val()) {
                                if ($('#password').val() == res[i].password) {
                                    location.href = 'http://cpdh49.natappfree.cc/home'
                                        // return false
                                } else {
                                    $('.long-bottom .err span').css('display', 'block')
                                    $('.long-top .err span').css('display', 'none')
                                    $('.cuowu').css('display', 'none')
                                }
                                // return false
                            } else {
                                // alert('账号不存在，请创建档案')
                                $('.long-top .err span').css('display', 'block')
                                $('.cuowu').css('display', 'none')
                            }
                            // return false
                        } else {
                            // alert('用户名和密码不能为空')
                            $('.cuowu').css('display', 'block')
                        }
                    }

                })





            }
        })
    </script>
</body>

</html>